package xyz.scoder;

public class FanOffCommand implements Command {
    private Fan fan;
    private int odd;

    public FanOffCommand(Fan fan) {
        this.fan = fan;
    }

    @Override
    public void execute() {
        // 设置新的速度前先保存之前的速度
        odd = fan.getSpeed();
        fan.setSpeed(Fan.OFF);
        System.out.println("关掉风扇");
    }

    @Override
    public void undo() {
        fan.setSpeed(odd);
    }
}
